package com.able.concurrency.t1;

/**
 * @author abel.he
 * @data 2018/8/15 18:40
 * @describe 同步方法：原子性，加锁的目的就是保证操作的原子性
 */
public class Test3 implements Runnable {

    private int count = 0;

    public /*synchronized*/ void run() {
        System.out.println(Thread.currentThread().getName() + "count:" + count++);
    }

    public static void main(String[] args) {
        Test3 test3 = new Test3();
        for (int i = 0; i < 10; i++) {
            new Thread(test3, "Thread" + i).start();
        }
    }
}
